/*------------------------------------------------------------------------------
$module:      lockers
$package:     CseApi
$purpose:     Windows implement for locker
$author:      WAYNE WORK STDIO
$CreateAt:    08/07/04
$LastModify:
$license:     Mozilla Public License Version 1.1
------------------------------------------------------------------------------*/

#include "CseApi/platform.h"
#include <windows.h>
#include <assert.h>

#include "CseApi/lockers.h"
#include "CseApi/CharArray.h"

struct critical_section_has
{   // same to: assert(CRITICAL_SECT_SIZE >= sizeof(CRITICAL_SECTION));
    // but check at compiler time
    int enough_space: CRITICAL_SECT_SIZE >= sizeof(CRITICAL_SECTION);
};

TCriticalSection::TCriticalSection()
{
    InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);
}

TCriticalSection::~TCriticalSection()
{
    DeleteCriticalSection((CRITICAL_SECTION *)m_buffer);
}

void TCriticalSection::enter()
{
    EnterCriticalSection((CRITICAL_SECTION *)m_buffer);
}

void TCriticalSection::leave()
{
    LeaveCriticalSection((CRITICAL_SECTION *)m_buffer);
}
